package com.hl.card.common.remote.resolve.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hl.card.common.remote.resolve.RemoteService;
import com.hl.card.common.remote.user.RemoteUser;
import com.hl.card.common.remote.user.RemoteUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class RemoteServiceImpl implements RemoteService {

    @Autowired
    private RemoteUserService remoteUserService;
    @Override
    public Map<String, Object> login(String loginAccount,String loginPwd, String gustId, String vrifyCode) {
        Map<String,Object> obj= (Map<String, Object>) remoteUserService.login( loginAccount,loginPwd, gustId,vrifyCode);
        return obj;
    }
    @Override
    public Map<String, Object> register(String loginAccount,String loginPwd,String phoneCode) {
        Map<String,Object> obj= (Map<String, Object>) remoteUserService.register(loginAccount,loginPwd,phoneCode);
        return obj;
    }
    @Override
    public RemoteUser findUserById(String userId) {
        Map<String,Object> obj= remoteUserService.findSsoUserByUserId(userId);
        if(obj.get("code").equals("0")){
          String str= JSON.toJSONString(obj.get("user"));
          return  JSONObject.parseObject(str,RemoteUser.class);
        }
        return null;
    }

}
